import { QuestionCircleFilled } from "@ant-design/icons"
import { Flex, Space, Tooltip } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import { ICardTablesBaseDetailResponse } from "@/api/business/types"
import BlindInjection from "@/components/common/showBlindInjection"
import { SLink } from "@/components/common/styled/container"
import { handleNumber, handleNumberColor } from "@/utils/util"

const tableList = (
	newFormat: (arg: string) => string,
	getFromDic: (arg: string, strictlyLabel?: boolean) => any,
	navigate: (to: string, state?: any) => void
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	tableList_gameTypeId: {
		key: "tableList_gameTypeId",
		align: "center",
		dataIndex: "gameTypeId",
		title: newFormat("dxn.card_ables_list.game_name"),
		width: 100,
		render: getFromDic("gameTypes", false)
	},
	tableList_tableType: {
		key: "tableList_tableType",
		align: "center",
		dataIndex: "tableType",
		title: newFormat("dxn.card_ables_list.blind_injection"),
		width: 120,
		render: (_: number, record: any) => {
			return (
				<BlindInjection
					tableType={record.tableType}
					bbBlindScore={record.bbBlindScore}
					sbBlindScore={record.sbBlindScore}
					anteSwitch={record.anteSwitch}
					anteScore={record.anteScore}
					straddleAmount={record.straddleAmount}
				/>
			)
		}
	},
	tableList_bringInChipScore: {
		key: "tableList_bringInChipScore",
		align: "center",
		dataIndex: "bringInChipScore",
		title: newFormat("dxn.card_ables_list.players_bring_in"),
		width: 100,
		render: (bringInChipScore: string, record: any) => handleNumber(record.currency, bringInChipScore)
	},
	tableList_bringOutChipScore: {
		key: "tableList_bringOutChipScore",
		align: "center",
		dataIndex: "bringOutChipScore",
		title: newFormat("dxn.card_ables_list.players_bring_out"),
		width: 100,
		render: (bringOutChipScore: string, record: any) => handleNumber(record.currency, bringOutChipScore)
	},

	tableList_evInsuredNetAmount: {
		key: "tableList_evInsuredNetAmount",
		align: "center",
		dataIndex: "evInsuredNetAmount",
		title: newFormat("dxn.game_list.ev_insurance"),
		width: 150,
		render: (evInsuredNetAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(evInsuredNetAmount) }}>{handleNumber(record.currency, `${evInsuredNetAmount}`)}</div>
		)
	},
	tableList_sendBarrageAmount: {
		key: "tableList_sendBarrageAmount",
		align: "center",
		dataIndex: "sendBarrageAmount",
		title: newFormat("dxn.game_list.post_barrages"),
		width: 150,
		render: (sendBarrageAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(sendBarrageAmount) }}>{handleNumber(record.currency, `${sendBarrageAmount}`)}</div>
		)
	},
	tableList_sendEmoteAmount: {
		key: "tableList_sendEmoteAmount",
		align: "center",
		dataIndex: "sendEmoteAmount",
		title: newFormat("dxn.game_list.send_an_emoji"),
		width: 150,
		render: (sendEmoteAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(sendEmoteAmount) }}>{handleNumber(record.currency, `${sendEmoteAmount}`)}</div>
		)
	},
	tableList_sendPuraseAmount: {
		key: "tableList_sendPuraseAmount",
		align: "center",
		dataIndex: "sendPuraseAmount",
		title: newFormat("dxn.game_list.send_phrases"),
		width: 150,
		render: (sendPuraseAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(sendPuraseAmount) }}>{handleNumber(record.currency, `${sendPuraseAmount}`)}</div>
		)
	},
	tableList_sendVoiceAmount: {
		key: "tableList_sendVoiceAmount",
		align: "center",
		dataIndex: "sendVoiceAmount",
		title: newFormat("dxn.game_list.make_a_voice"),
		width: 150,
		render: (sendVoiceAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(sendVoiceAmount) }}>{handleNumber(record.currency, `${sendVoiceAmount}`)}</div>
		)
	},
	tableList_interactPropAmount: {
		key: "tableList_interactPropAmount",
		align: "center",
		dataIndex: "interactPropAmount",
		title: newFormat("dxn.game_list.interactive_props"),
		width: 150,
		render: (interactPropAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(interactPropAmount) }}>{handleNumber(record.currency, `${interactPropAmount}`)}</div>
		)
	},
	tableList_lookPublicCardAmount: {
		key: "tableList_lookPublicCardAmount",
		align: "center",
		dataIndex: "lookPublicCardAmount",
		title: newFormat("dxn.game_list.look_at_public_cards"),
		width: 150,
		render: (lookPublicCardAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(lookPublicCardAmount) }}>
				{handleNumber(record.currency, `${lookPublicCardAmount}`)}
			</div>
		)
	},
	tableList_betActionDelayAmount: {
		key: "tableList_betActionDelayAmount",
		align: "center",
		dataIndex: "betActionDelayAmount",
		title: newFormat("dxn.game_list.delay_in_placing_bets"),
		width: 150,
		render: (betActionDelayAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(betActionDelayAmount) }}>
				{handleNumber(record.currency, `${betActionDelayAmount}`)}
			</div>
		)
	},
	tableList_insureActionDelayAmount: {
		key: "tableList_insureActionDelayAmount",
		align: "center",
		dataIndex: "insureActionDelayAmount",
		title: newFormat("dxn.game_list.insurance_action_delay"),
		width: 150,
		render: (insureActionDelayAmount: number, record: any) => (
			<div style={{ color: handleNumberColor(insureActionDelayAmount) }}>
				{handleNumber(record.currency, `${insureActionDelayAmount}`)}
			</div>
		)
	},
	tableList_costTotal: {
		key: "tableList_costTotal",
		align: "center",
		dataIndex: "costTotal",
		title: (
			<Flex vertical={false}>
				{newFormat("dxn.card_ables_list.total_table_profit_and_loss")}
				<Tooltip placement="top" title={newFormat("dxn.game_list.cost_total_tip")}>
					<QuestionCircleFilled style={{ marginLeft: 5 }} />
				</Tooltip>
			</Flex>
		),
		width: 130,
		render: (costTotal: string, record: any) => (
			<div style={{ color: handleNumberColor(record.costTotal) }}>{handleNumber(record.currency, costTotal)}</div>
		)
	},
	tableList_operation: {
		key: "tableList_operation",
		align: "center",
		dataIndex: "tableType",
		title: newFormat("dxn.card_ables_list.operate"),
		fixed: "right",
		width: 270,
		render: (_: string, record: any) => (
			<Space>
				<SLink onClick={() => navigate(`/dxn/gameManager/cardTablesList/cardTablesBase?tableId=${record.tableCode}`)}>
					{newFormat("routes.dxn.card_tables_list_game_base")}
				</SLink>
				<SLink onClick={() => navigate(`/dxn/insureManager/insureList?tableId=${record.tableCode}`)}>
					{newFormat("routes.dxn.insure_detail")}
				</SLink>
				<SLink onClick={() => navigate(`/dxn/orderManager/orderList?tableId=${record.tableCode}`)}>
					{newFormat("routes.dxn.order_list_route")}
				</SLink>
				<SLink onClick={() => navigate(`/dxn/squidManager/squidList?tableCode=${record.tableCode}`)}>
					{newFormat("routes.dxn.squid_list")}
				</SLink>
			</Space>
		)
	},
	tableList_bringChipTotal: {
		key: "bringChipTotal",
		dataIndex: "bringChipTotal",
		title: newFormat("dxn.card_ables_list.players_bring_in2"),
		align: "center",
		width: 100,
		render: (currency: string, record: ICardTablesBaseDetailResponse) => handleNumber(currency, record.bringChipTotal.toString())
	},
	tableList_afterChipTotal: {
		key: "afterChipTotal",
		dataIndex: "afterChipTotal",
		title: newFormat("dxn.card_ables_list.players_bring_out2"),
		align: "center",
		width: 100,
		render: (currency: string, record: ICardTablesBaseDetailResponse) => handleNumber(currency, record.afterChipTotal.toString())
	},
	tableList_costTotal1: {
		key: "costTotal",
		dataIndex: "costTotal",
		title: newFormat("dxn.card_ables_list.cost_total"),
		align: "center",
		width: 120,
		render: (costTotal: string, record: any) => (
			<div style={{ color: handleNumberColor(record.costTotal) }}>{handleNumber(record.currency, costTotal)}</div>
		)
	}
})
export default tableList
